#include <iostream>
#include <set>
using std::cout;
using std::endl;
using std::set;

void test0(){
    set<int> nums;
    set<int> nums2{4,5,1,2,3,5,2,3};
    set<int> nums3(nums2);
    set<int> nums4(nums2.begin(),nums2.end());

    //set不支持下标操作
    /* nums[0]; */

    //set的特点：
    //元素去重
    //自动对元素进行升序排列
    for(auto & ele : nums2){
        cout << ele << " ";
    }
    cout << endl;

    /* set<int>::iterator it = nums4.begin(); */
    auto it = nums4.begin();
    for(; it != nums4.end(); ++it){
        cout << *it << " ";
    }
    cout << endl;

    //查找操作
    cout << endl;
    cout << nums2.count(2) << endl;
    cout << nums2.count(20) << endl;

    auto it2 = nums2.find(10);
    if(it2 != nums2.end()){
        cout << "该元素存在于set中" << endl;
        cout << "*it2:" << *it2 << endl;
    }else{
        cout << "该元素不存在" << endl;
    }
}

int main(void){
    test0();
    return 0;
}
